package com.bilibilifans.data.Fans;


import com.bilibilifans.data.MyCode;
import com.bilibilifans.data.UpInformation;


import java.util.*;


/**
 * @author 司啸飞
 * @create 2021-05-11 21:48
 */
public class GetFansNumber {

    static final String URL_BEFORE = "https://api.bilibili.com/x/relation/stat?vmid=";
    static final String URl_AFTER = "&jsonp=jsonp";

    /**
     * 将获取到的数据进行转换，添加进UpInformation类的imap中
     * @param
     * @throws Exception
     */
    public static void getData(String mid) throws Exception{
        // 创建临时map接收到 粉丝API源码
        HashMap<String, String> temp = MyCode.getCode(URL_BEFORE + mid + URl_AFTER, UpInformation.GET_FANSNUMBER);
        for (Map.Entry<String, String> entry : temp.entrySet()) {
            String key = entry.getKey();
            Integer value = Integer.parseInt(entry.getValue());
            // 将转换好的 key,value 添加到UpInformation类的imap中
            UpInformation.getiMap().put(key, value);
        }

    }



    public static void main(String[] args) throws Exception {
        GetFansNumber fn = new GetFansNumber();
        GetFansNumber.getData("672328094");
        System.out.println(UpInformation.getiMap());
    }
}
